home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / src / net / bind-contrib.tar.gz / bind-contrib.tar / contrib / misc / updatedns.shar / makeHS.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-25  |  789 b   |  36 lines

  1. /* Copy stdin to stdout, substituting any %s for the current timestamp
  2.  * (hacked out of makeDNS.c).  The idea is that the HS-class header should
  3.  * just $INCLUDE anything it needs, which will have been generated separately.
  4.  */
  5.  
  6. #include <stdio.h>
  7. #include <sys/types.h>
  8. #include <sys/time.h>
  9. #include <time.h>
  10.  
  11. #define LINEBUFFER 120
  12. #define LOG "/dev/tty"
  13.  
  14. int main()
  15. {    time_t tt;
  16.     struct tm *ttm;
  17.     char *t;
  18.     char stamp[20];
  19.     char buffer[LINEBUFFER];
  20.  
  21.     tt = time(NULL);
  22.     ttm = localtime(&tt);
  23.     (void) sprintf(stamp, "%d%3.3d%3.3d",
  24.         ttm->tm_year, ttm->tm_yday,
  25.         ((60 * ttm->tm_hour) + ttm->tm_min) >> 1);
  26.     t = asctime(ttm);
  27.  
  28.     (void) printf(";; Generated on %s\n", t);
  29.  
  30.     for (;;) {
  31.         if (fgets(buffer, LINEBUFFER, stdin) == NULL) break;
  32.         (void) printf(buffer, stamp);
  33.     }
  34.     return 0;
  35. }
  36.